package cn.bandeqing.sys.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.base.resp.Table;
import cn.bandeqing.sys.req.*;
import cn.bandeqing.sys.resp.*;
import cn.bandeqing.sys.rpc.ISysRpc;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/sys")
@RestController
@Tag(name = "系统")
public class SysController {

    @DubboReference
    private ISysRpc sysRpc;

    @Operation(summary = "unipush2")
    @PostMapping("/unipush2/table")
    public Resp<Table<Unipush2Table>> unipush2Table(@RequestBody @Valid Unipush2TableReq req) {
        return sysRpc.unipush2Table(req);
    }

    @Operation(summary = "equipment")
    @PostMapping("/equipment/table")
    public Resp<Table<EquipmentTable>> equipmentTable(@RequestBody @Valid EquipmentTableReq req) {
        return sysRpc.equipmentTable(req);
    }

    @Operation(summary = "appTable")
    @PostMapping("/app/table")
    public Resp<Table<AppTable>> appTable(@RequestBody @Valid AppTableReq req) {
        return sysRpc.appTable(req);
    }

    @Operation(summary = "appSaveOrUpdate")
    @PostMapping("/appSaveOrUpdate")
    public Resp<Void> appSaveOrUpdate(@RequestBody @Valid AppSaveOrUpdateReq req) {
        sysRpc.appSaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "dictListTable")
    @PostMapping("/dictListTable")
    public Resp<Table<DictListTable>> dictListTable(@RequestBody @Valid DictListTableReq req) {
        return sysRpc.dictListTable(req);
    }

    @Operation(summary = "dictListSaveOrUpdate")
    @PostMapping("/dictListSaveOrUpdate")
    public Resp<Void> dictListSaveOrUpdate(@RequestBody @Valid DictListSaveOrUpdateReq req) {
        sysRpc.dictListSaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "dictTypeTable")
    @PostMapping("/dictTypeTable")
    public Resp<Table<DictTypeTable>> dictTypeTable(@RequestBody @Valid DictTypeTableReq req) {
        return sysRpc.dictTypeTable(req);
    }

    @Operation(summary = "dictTypeSaveOrUpdate")
    @PostMapping("/dictTypeSaveOrUpdate")
    public Resp<Void> dictTypeSaveOrUpdate(@RequestBody @Valid DictTypeSaveOrUpdateReq req) {
        sysRpc.dictTypeSaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "cityTable")
    @PostMapping("/cityTable")
    public Resp<Table<CityTable>> cityTable(@RequestBody @Valid CityTableReq req) {
        return sysRpc.cityTable(req);
    }

    @Operation(summary = "citySaveOrUpdate")
    @PostMapping("/citySaveOrUpdate")
    public Resp<Void> citySaveOrUpdate(@RequestBody @Valid CitySaveOrUpdateReq req) {
        sysRpc.citySaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "dictType")
    @PostMapping("/dictType")
    public Resp<List<DictTypeSelect>> dictType(@RequestBody @Valid DictTypeReq req) {
        return sysRpc.dictType(req);
    }

    @Operation(summary = "getAuths")
    @PostMapping("/getAuths")
    public Resp<List<Long>> getAuths(@RequestBody @Valid GetAuthsReq req) {
        return sysRpc.getAuths(req);
    }

    @Operation(summary = "roleAuths")
    @PostMapping("/roleAuths")
    public Resp<Void> roleAuths(@RequestBody @Valid RoleAuthsReq req) {
        return sysRpc.roleAuths(req);
    }

    @Operation(summary = "roleAuthTree")
    @PostMapping("/roleAuthTree")
    public Resp<List<RoleAuthTree>> roleAuthTree() {
        return sysRpc.roleAuthTree();
    }

    @Operation(summary = "authorityTable")
    @PostMapping("/authorityTable")
    public Resp<Table<AuthorityTable>> authorityTable(@RequestBody @Valid AuthorityTableReq req) {
        return sysRpc.authorityTable(req);
    }

    @Operation(summary = "创建或更新")
    @PostMapping("/authoritySaveOrUpdate")
    public Resp<Void> authoritySaveOrUpdate(@RequestBody @Valid AuthoritySaveOrUpdateReq req) {
        sysRpc.authoritySaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "roleTable")
    @PostMapping("/roleTable")
    public Resp<Table<RoleTable>> roleTable(@RequestBody @Valid RoleTableReq req) {
        return sysRpc.roleTable(req);
    }

    @Operation(summary = "创建或更新")
    @PostMapping("/roleSaveOrUpdate")
    public Resp<Void> roleSaveOrUpdate(@RequestBody @Valid RoleSaveOrUpdateReq req) {
        sysRpc.roleSaveOrUpdate(req);
        return Resp.success();
    }

    @Operation(summary = "configTable")
    @PostMapping("/configTable")
    public Resp<Table<ConfigTable>> configTable(@RequestBody @Valid ConfigTableReq req) {
        return sysRpc.configTable(req);
    }

    @Operation(summary = "创建或更新")
    @PostMapping("/configSaveOrUpdate")
    public Resp<Void> configSaveOrUpdate(@RequestBody @Valid ConfigSaveOrUpdateReq req) {
        sysRpc.configSaveOrUpdate(req);
        return Resp.success();
    }

}
